package com.tougutips.like.config;


import com.tougutips.like.enums.LikeEnums;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    @Bean
    public Queue likeQueue(){
        return new Queue(LikeEnums.QUEUE_NAME.getValue());
    }

    @Bean
    public Queue messageQueue(){
        return new Queue(LikeEnums.MESSAGE_QUEUE_NAME.getValue());
    }

    @Bean
    public TopicExchange likeExchange(){
        return new TopicExchange(LikeEnums.EXCHANGE_NAME.getValue(),true,false);
    }

    @Bean
    public Binding bindingQueueToExchange(){
        return BindingBuilder.bind(likeQueue()).to(likeExchange()).with(LikeEnums.LIKE_QUEUE_ROUTING_KEY.getValue());
    }

    @Bean
    public Binding bindingMessageQueueToExchange(){
        return BindingBuilder.bind(messageQueue()).to(likeExchange()).with(LikeEnums.MESSAGE_QUEUE_ROUTING_KEY.getValue());
    }
}
